package com.test.reggieadmin.model.fragment.employee;

import com.test.reggieadmin.base.BaseObserver;
import com.test.reggieadmin.base.BasePresenter;
import com.test.reggieadmin.bean.BaseBean;
import com.test.reggieadmin.bean.PageBean;

import java.util.Map;

public class EmployeePrensenter extends BasePresenter<EmployeeView> {
    public EmployeePrensenter(EmployeeView baseView) {
        super(baseView);
    }

    /**
     * 分页查询员工列表
     */
    public void page(int skip, int pageSize, String name, int type) {
        addDisposable(apiServer.page(skip, pageSize, name), new BaseObserver<PageBean>() {
            @Override
            public void onSuccess(PageBean bean) {
                baseView.pageData(bean, type);
            }

            @Override
            public void onError(String msg) {
                baseView.pageError(msg);
            }
        });
    }

    /**
     * 修改员工信息
     *
     * @param map
     */
    public void update(Map<String, Object> map) {
        addDisposable(apiServer.update(map), new BaseObserver<BaseBean>() {
            @Override
            public void onSuccess(BaseBean bean) {
                baseView.updateData(bean);
            }

            @Override
            public void onError(String msg) {
                baseView.onError(msg);
            }
        });
    }
}
